home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 015 / sidepc.arc / SIDEPC.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1986-01-06  |  5.1 KB  |  149 lines

  1.  
  2.  
  3. {$line+,$symtab-,$linesize:131,$pagesize:65}
  4. program SIDEPC(input,output,infile);
  5.  
  6. {This program will print the `infile' sideways on an Oki PCWRITER Printer.
  7.  As the PCWRITER uses the IBM Graphics Instruction set, this pgm should
  8.  run unmodified on the IBM Graphics printer.  By looking at the entries
  9.  in the const. tables, modifications for other printers can be made.
  10.  It makes use of the characters in the PC's ROM for the graphics mode of
  11.  the CRT. The characters in the file are `looked up' and then the graphics
  12.  mode of the printer is used for output.}
  13.  
  14. { The DEBUG statements will output on the CRT the current line being printed.
  15.   The line will appear vertically. }
  16.  
  17. type
  18.     vstr = super array[0..*] of char;
  19.     CHAR_PER_LINE = 0..2000;        {Maximum input line size}
  20.     FNAME = packed array[1..15] of char;
  21.     PSIZER = 1..2;
  22. const
  23.     EOF = chr(26);            {TEXT EOF character}
  24.     EOL = chr(13);
  25.     TAB = chr(9);            {expand TABs}
  26.     IGNORE = [chr(0)..chr(8),chr(10)..chr(#1f),chr(#80)..chr(#FF)];
  27.     MAX_LINES = 48*2;            {Lines/Page}
  28.     SPACES_PER_LINE = 2;        {2/72th inch space between lines}
  29.     SPACES_PER_LETTER = 8;        {DOT size of characters}
  30.     { PCWRITER ADDITIONS - TO SHIFT GRAPHICS MODES }
  31.     FEED = chr(27)*chr(65);        { ESCape A (sel. var. space) }
  32.     FEEDSET = CHR(27)*CHR(50);    { ESCape 2 (use Esc A set spacing)}
  33.     L3 = chr(27);                { ESCAPE }
  34.     L1 = chr(76);                { 'L' for 120 dpi graphics}
  35.     L2 = chr(75);                { 'K' for  60 dpi graphics}
  36.     W = chr(8);                    { Large Char Linefeed spacing }
  37.     N = chr(7);                    { Small Char Linefeed spacing }
  38. var
  39.     psize : PSIZER;
  40.     lptr : array[1..MAX_LINES] of ^vstr; {input lines}
  41.     inbuf : array[CHAR_PER_LINE] of char;
  42.     linesize : CHAR_PER_LINE;
  43.     linemax : integer;
  44.     indx : 0..MAX_LINES;
  45.     line : 0..MAX_LINES+1;
  46.     infile : file of char;
  47.     printer : text;
  48.     col : CHAR_PER_LINE;
  49.     pchar : integer;
  50.     ichar : 0..7;
  51.     max : CHAR_PER_LINE;
  52.     rom : ads of array[0..32000] of char;
  53.     prints : FNAME;
  54.     GRAPHMODE : char;
  55.     GRAPHFEED : char;
  56.     scroll : integer;
  57.  
  58. value
  59.   {NOTE!!!!
  60.      The following declarations define the segment and offset values
  61.      for the characters in the PC version of the ROM. For the XT, check
  62.      the TECH MANUAL for the correct values.}
  63.  
  64.     rom.s := #F000; {address of the CRT character generation}
  65.     rom.r := #FA6E; {matrix in the ROM -- for non-XT versions of PC}
  66.  
  67. begin
  68.     for scroll := 1 to 11 do writeln(output);
  69.     writeln(output,'Enter name of file to write, [RETURN] for printer');
  70.     for scroll := 1 to 11 do writeln(output);
  71.     readln(prints);
  72.     if prints = '               ' then prints :='lpt1:          ' else prints := prints;
  73.  
  74.     for scroll := 1 to 11 do writeln(output);
  75.     writeln(output,'Select [1] Normal or [2] Compressed printing');
  76.     for scroll := 1 to 11 do writeln(output);
  77.     readln(psize);
  78.     if (psize = 1) then begin
  79.         GRAPHMODE := L2;
  80.         GRAPHFEED := W;
  81.         linemax := (MAX_LINES div 2);
  82.         end
  83.     else begin
  84.         GRAPHMODE := L1;
  85.         GRAPHFEED := N;
  86.         linemax := (MAX_LINES);
  87.         end;
  88.     assign(printer,prints);            {open output file or the printer}
  89.     rewrite(printer);
  90.     reset(infile);
  91.     repeat
  92.     max := 0;
  93.     linesize := 0;
  94.     line := 1;
  95.     while (line <= linemax) do begin
  96.         if infile^ = EOL then begin {check for End-of-Line}
  97.         new(lptr[line],linesize+1);  {allocate string storage}
  98.         movel(adr inbuf[0],adr lptr[line]^[0],wrd(linesize+1)); {save}
  99.         if linesize > max then max := linesize;
  100.         linesize := 0;
  101.         line := line+1;
  102.         get(infile);
  103.         writeln(output,'<<');   {--DEBUG--}
  104.         cycle;
  105.         end;
  106.         if infile^ = EOF then break;
  107.         if not(infile^ in IGNORE) then begin
  108.         if infile^ = TAB then
  109.             repeat        {Expand TABs}
  110.             linesize := linesize+1;
  111.             inbuf[linesize] := ' ';
  112.             until (linesize mod 8) = 0
  113.         else begin
  114.             linesize := linesize+1;
  115.             inbuf[linesize] := infile^;
  116.         end;
  117.         write(output,infile^);    {--DEBUG--}
  118.         end;
  119.         get(infile);
  120.     end;
  121.     writeln(output,'line=',line,' max=',max);  {--DEBUG--}
  122.     if infile^ <> EOF then line := linemax
  123.     else line := line-1;
  124.     for col := 1 to max do begin    {Output collected lines}
  125.         write(printer,FEED,GRAPHFEED,FEEDSET,L3,GRAPHMODE,
  126.              chr((line*(8+SPACES_PER_LINE)) mod 256),
  127.              chr((line*(8+SPACES_PER_LINE)) div 256));
  128.         for indx := line downto 1 do begin    {Scan next column}
  129.         {if column pointer is larger than string, output BLANK}
  130.         if col > (upper(lptr[indx]^)-1) then pchar := ord(' ')
  131.         else pchar := ord(lptr[indx]^[col]);
  132.         write(output,chr(pchar));  {--DEBUG--}
  133.         pchar := pchar*8;
  134.         for ichar := 7 downto 0 do  {Pickup character, a line at a time, }
  135.             write(printer,rom^[pchar+ichar]); {from ROM}
  136.         for ichar := 1 to SPACES_PER_LINE do write(printer,chr(0));
  137.         end;
  138.         writeln(printer);
  139.         writeln(output);        {--DEBUG--}
  140.     end;
  141.     for indx := 1 to line do dispose(lptr[indx]);  {Free up space on HEAP}
  142.     page(printer);
  143.     until infile^ = EOF;
  144.     if (prints <> 'lpt1:          ' ) then page(printer);        {final eject; when using a file for output, will allow
  145.                         a [ copy <filename> prn ] instruction where <filename>
  146.                         is a wildcard.}
  147. end.
  148.  
  149.